/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { Global, Module } from '@nestjs/common';
import { WinstonModule } from 'nest-winston';
import { winstonConfig } from './winston.config';
import { APP_INTERCEPTOR } from '@nestjs/core';
import { LoggerInterceptor } from './logger.intercepter';

@Global()
@Module({
  imports: [
    // eslint-disable-next-line @typescript-eslint/no-unsafe-call
    WinstonModule.forRootAsync({
      useFactory: () => ({
        ...winstonConfig,
      }),
    }),
  ],
  providers: [
    {
      provide: APP_INTERCEPTOR,
      useClass: LoggerInterceptor,
    },
  ],
  exports: [WinstonModule],
})
export class WinstonLoggerModule {}
